#ifndef _DICOM_REF_OBJECT_H_
#define _DICOM_REF_OBJECT_H_

#include <stdint.h>
#include <boost/noncopyable.hpp>
#include <gwbase/base/atomic.h>

namespace dicom {

// After create a RefObject, the reference count is zero, so you MUST
// call AddRef() once immediately.
class RefObject : public boost::noncopyable {
 public:
  RefObject(int obj_type = 0);
  virtual ~RefObject();

  void AddRef();
  void Unref();

  int obj_type() const { return obj_type_; }
  int64_t obj_id() const { return obj_id_; }

 protected:
  AtomicInt32 refs_;
  int obj_type_;
  int64_t obj_id_;
};
}

#endif  // _DICOM_REF_OBJECT_H_
